package com.ogilvy.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsPageVersions;
import com.ogilvy.cms.dao.CmsPageVersionsDao;
import com.ogilvy.cms.service.CmsPageVersionsService;
import com.ogilvy.frame.service.BaseServiceImpl;

@Service
public class CmsPageVersionsServiceImpl extends BaseServiceImpl implements CmsPageVersionsService {
	@Autowired
	protected CmsPageVersionsDao cmsPageVersionsDao;
	//实现新增
	public CmsPageVersions add(CmsPageVersions cmsPageVersions) {
		CmsPageVersions cmspageversions = cmsPageVersionsDao.save(cmsPageVersions);
		return cmspageversions;
	}
	//实现删除
	public boolean del(Integer cpveId) {
		cmsPageVersionsDao.deleteById(cpveId);
		return true;
	}
	//实现修改
	public boolean modify(CmsPageVersions cmsPageVersions) {
		cmsPageVersionsDao.update(cmsPageVersions);
		return true;		
	}
	//实现查询
	public List<CmsPageVersions> query(CmsPageVersions cmsPageVersions) {
		if(!isEmpty(cmsPageVersions.getCpveVersionsName())){
			return cmsPageVersionsDao.findByProperty("cpveVersionsName", cmsPageVersions.getCpveVersionsName());
		}
//		if(!isEmpty(cmsPageVersions.getParentCmdId()))
//		{
//			return cmsPageVersionsDao.findByProperty("parentCmdId", cmsPageVersions.getParentCmdId());
//		}
		return cmsPageVersionsDao.findAll();
	}
	//通过ID进行查询
	public CmsPageVersions get(Integer cpveId){
		return cmsPageVersionsDao.get(cpveId);
	}
	
	 /**根据筛选条件查询相关信息*/
	public List<CmsPageVersions> queryByScreen(Map<String, String> screenMap) {
		return cmsPageVersionsDao.getListByScreen(screenMap);
	}

}
